﻿// -----------------------------------------------------------------------
// <copyright file="TableFullAccessRight.cs" company="JSC Centido">
//  Copyright (c) JSC Centido. All rights reserved.
// </copyright>
// -----------------------------------------------------------------------

namespace Centido.Core
{
    using System;

    /// <summary>
    ///   A Security table full access right.
    /// </summary>
    public sealed class TableFullAccessRight : ITableAccessRight
    {
        /// <summary>
        ///   The access type.
        /// </summary>
        private readonly DataAction _dataAction;

        /// <summary>
        ///   The target table.
        /// </summary>
        private readonly Table _table;

        /// <summary>
        ///   The target user.
        /// </summary>
        private readonly User _user;


        /// <summary>
        ///   Creates a new instance of the <see cref="Centido.Core.TableFullAccessRight"/> class.
        /// </summary>
        /// <param name="table">The target table.</param>
        /// <param name="user">The target user.</param>
        /// <param name="dataAction">The data action.</param>
        /// <exception cref="ArgumentNullException">Thrown when the value of <paramref name="table"/> is null.</exception>
        /// <exception cref="ArgumentNullException">Thrown when the value of <paramref name="user"/> is null.</exception>
        internal TableFullAccessRight(Table table, User user, DataAction dataAction)
        {
            if (table == null)
                throw new ArgumentNullException("table");
            if (user == null)
                throw new ArgumentNullException("user");

            _table = table;
            _user = user;
            _dataAction = dataAction;
        }

        #region ITableAccessRight Members

        /// <summary>
        ///   Gets the target table.
        /// </summary>
        public Table Table
        {
            get { return _table; }
        }

        /// <summary>
        ///   Gets the target user.
        /// </summary>
        public User User
        {
            get { return _user; }
        }

        /// <summary>
        ///   Gets the data action.
        /// </summary>
        public DataAction DataAction
        {
            get { return _dataAction; }
        }

        #endregion
    }
}